package com.ruoyi.web.controller.eamp;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.eamp.domain.EampEquipment;
import com.ruoyi.eamp.domain.vo.EampEquipmentMyAndEquip;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.eamp.domain.EampEquipmentMy;
import com.ruoyi.eamp.service.IEampEquipmentMyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 我的仪器使用Controller
 * 
 * @author ruoyi
 * @date 2024-08-08
 */
@RestController
@RequestMapping("/eamp/equipment_my")
public class EampEquipmentMyController extends BaseController
{
    @Autowired
    private IEampEquipmentMyService eampEquipmentMyService;

    /**
     * 查询我的仪器使用列表
     */
    @PreAuthorize("@ss.hasPermi('eamp:equipment_my:list')")
    @GetMapping("/list")
    public TableDataInfo list(EampEquipmentMyAndEquip eampEquipmentMy)
    {
        startPage();
        List<EampEquipmentMyAndEquip> list = eampEquipmentMyService.selectEampEquipmentMyList(eampEquipmentMy);
        return getDataTable(list);
    }


    /**
     * 导出我的仪器使用列表
     */
    @PreAuthorize("@ss.hasPermi('eamp:equipment_my:export')")
    @Log(title = "我的仪器使用", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EampEquipmentMyAndEquip eampEquipmentMy)
    {
        List<EampEquipmentMyAndEquip> list = eampEquipmentMyService.selectEampEquipmentMyList(eampEquipmentMy);
        ExcelUtil<EampEquipmentMyAndEquip> util = new ExcelUtil<EampEquipmentMyAndEquip>(EampEquipmentMyAndEquip.class);
        util.exportExcel(response, list, "我的仪器使用数据");
    }

    /**
     * 获取我的仪器使用详细信息
     */
    @PreAuthorize("@ss.hasPermi('eamp:equipment_my:query')")
    @GetMapping(value = "/{equipmentLogId}")
    public AjaxResult getInfo(@PathVariable("equipmentLogId") Long equipmentLogId)
    {
        return success(eampEquipmentMyService.selectEampEquipmentMyByEquipmentLogId(equipmentLogId));
    }

    /**
     * 新增我的仪器使用
     */
    @PreAuthorize("@ss.hasPermi('eamp:equipment_my:add')")
    @Log(title = "我的仪器使用", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EampEquipmentMy eampEquipmentMy)
    {
        return toAjax(eampEquipmentMyService.insertEampEquipmentMy(eampEquipmentMy));
    }

    /**
     * 修改我的仪器使用
     */
    @PreAuthorize("@ss.hasPermi('eamp:equipment_my:edit')")
    @Log(title = "我的仪器使用", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EampEquipmentMy eampEquipmentMy)
    {
        return toAjax(eampEquipmentMyService.updateEampEquipmentMy(eampEquipmentMy));
    }

    /**
     * 删除我的仪器使用
     */
    @PreAuthorize("@ss.hasPermi('eamp:equipment_my:remove')")
    @Log(title = "我的仪器使用", businessType = BusinessType.DELETE)
	@DeleteMapping("/{equipmentLogIds}")
    public AjaxResult remove(@PathVariable Long[] equipmentLogIds)
    {
        return toAjax(eampEquipmentMyService.deleteEampEquipmentMyByEquipmentLogIds(equipmentLogIds));
    }


    @PreAuthorize("@ss.hasPermi('eamp:equipment_my:listt')")
    @GetMapping("/listt")
    public TableDataInfo listt(EampEquipmentMyAndEquip eampEquipmentMyAndEquip)
    {

        List<EampEquipmentMyAndEquip> list = eampEquipmentMyService.selecteampEquipmentMyAndEquip(eampEquipmentMyAndEquip);
        return getDataTable(list);
    }
    /**
     * 入库仪器设备详细信息
     */
    @PreAuthorize("@ss.hasPermi('eamp:equipment_my:in')")
    @PutMapping(value = "/in")
    public AjaxResult getin(@RequestBody EampEquipmentMy eampEquipmentMy)
    {
        return toAjax(eampEquipmentMyService.inable(eampEquipmentMy));
    }
}
